package com.xbao.dao;

import com.xbao.model.MySpread;
import com.xbao.model.MySpreadExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface MySpreadMapper {
    @SelectProvider(type=MySpreadSqlProvider.class, method="countByExample")
    int countByExample(MySpreadExample example);

    @DeleteProvider(type=MySpreadSqlProvider.class, method="deleteByExample")
    int deleteByExample(MySpreadExample example);

    @Delete({
        "delete from my_spread",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into my_spread (eid, orgid, ",
        "createtime, updatetime, ",
        "templateid, comments, ",
        "title, body)",
        "values (#{eid,jdbcType=BIGINT}, #{orgid,jdbcType=BIGINT}, ",
        "#{createtime,jdbcType=BIGINT}, #{updatetime,jdbcType=BIGINT}, ",
        "#{templateid,jdbcType=BIGINT}, #{comments,jdbcType=VARCHAR}, ",
        "#{title,jdbcType=LONGVARCHAR}, #{body,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MySpread record);

    @InsertProvider(type=MySpreadSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MySpread record);

    @SelectProvider(type=MySpreadSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="templateid", property="templateid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="body", property="body", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<MySpread> selectByExampleWithBLOBs(MySpreadExample example);

    @SelectProvider(type=MySpreadSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="templateid", property="templateid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR)
    })
    List<MySpread> selectByExample(MySpreadExample example);

    @Select({
        "select",
        "id, eid, orgid, createtime, updatetime, templateid, comments, title, body",
        "from my_spread",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="templateid", property="templateid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="body", property="body", jdbcType=JdbcType.LONGVARCHAR)
    })
    MySpread selectByPrimaryKey(Long id);

    @UpdateProvider(type=MySpreadSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") MySpread record, @Param("example") MySpreadExample example);

    @UpdateProvider(type=MySpreadSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") MySpread record, @Param("example") MySpreadExample example);

    @UpdateProvider(type=MySpreadSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") MySpread record, @Param("example") MySpreadExample example);

    @UpdateProvider(type=MySpreadSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MySpread record);

    @Update({
        "update my_spread",
        "set eid = #{eid,jdbcType=BIGINT},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "templateid = #{templateid,jdbcType=BIGINT},",
          "comments = #{comments,jdbcType=VARCHAR},",
          "title = #{title,jdbcType=LONGVARCHAR},",
          "body = #{body,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(MySpread record);

    @Update({
        "update my_spread",
        "set eid = #{eid,jdbcType=BIGINT},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "templateid = #{templateid,jdbcType=BIGINT},",
          "comments = #{comments,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MySpread record);
}